﻿using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NTmdb.TestProject
{
    /// <summary>
    ///     This is a test class for TmdbAlternativeTitleTest and is intended
    ///     to contain all TmdbAlternativeTitleTest Unit Tests
    /// </summary>
    [TestClass]
    public class TmdbAlternativeTitleTest
    {
        /// <summary>
        ///     A test for TmdbAlternativeTitle Constructor
        /// </summary>
        [TestMethod]
        public void TmdbAlternativeTitleConstructorTest()
        {
            var target = new TmdbAlternativeTitle();
            Assert.IsNotNull( target );
        }

        /// <summary>
        ///     A test for Iso3166_1
        /// </summary>
        [TestMethod]
        public void Iso3166_1Test()
        {
            var target = new TmdbAlternativeTitle();
            string expected = Guid.NewGuid().ToString();
            target.Iso3166_1 = expected;
            string actual = target.Iso3166_1;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Title
        /// </summary>
        [TestMethod]
        public void TitleTest()
        {
            var target = new TmdbAlternativeTitle();
            string expected = Guid.NewGuid().ToString();
            string actual;
            target.Title = expected;
            actual = target.Title;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Serialize & Deserialize
        /// </summary>
        [TestMethod]
        [DeploymentItem(@"..\..\TestData\alternativeTitle.json.txt")]
        public async Task SerializeDeserializeTest()
        {
            var target = new TmdbAlternativeTitle();
            var jsonContent = File.ReadAllText("alternativeTitle.json.txt");
            var actual = await target.DeserializeJson<TmdbAlternativeTitle>(jsonContent);

            Assert.AreEqual("Podziemny krag", actual.Title);
            Assert.AreEqual("TW", actual.Iso3166_1);
        }
    }
}